﻿using System;
using System.Collections.Generic;
using Communication.Channel;

namespace Communication.Bootstrap
{
	// Token: 0x02000004 RID: 4
	public class Bootstrap
	{
		// Token: 0x06000033 RID: 51 RVA: 0x00002050 File Offset: 0x00000250
		protected Bootstrap()
		{
		}

		// Token: 0x06000034 RID: 52 RVA: 0x00002065 File Offset: 0x00000265
		protected Bootstrap(ChannelFactory channelFactory)
		{
			this.SetFactory(channelFactory);
		}

		// Token: 0x06000035 RID: 53 RVA: 0x00002084 File Offset: 0x00000284
		public ChannelFactory GetFactory()
		{
			ChannelFactory channelFactory = this.factory;
			if (channelFactory == null)
			{
				throw new InvalidOperationException("factory is not set yet.");
			}
			return channelFactory;
		}

		// Token: 0x06000036 RID: 54 RVA: 0x000020A9 File Offset: 0x000002A9
		public void SetFactory(ChannelFactory factory)
		{
			if (factory == null)
			{
				throw new ArgumentNullException("factory");
			}
			if (this.factory != null)
			{
				throw new InvalidOperationException("factory can't change once set.");
			}
			this.factory = factory;
		}

		// Token: 0x06000037 RID: 55 RVA: 0x000020D7 File Offset: 0x000002D7
		public Dictionary<string, object> GetOptions()
		{
			return new Dictionary<string, object>(this.options);
		}

		// Token: 0x06000038 RID: 56 RVA: 0x000020E6 File Offset: 0x000002E6
		public void SetOptions(IDictionary<string, object> options)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			this.options = new Dictionary<string, object>(options);
		}

		// Token: 0x06000039 RID: 57 RVA: 0x00002104 File Offset: 0x00000304
		public object GetOption(string key)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			return this.options[key];
		}

		// Token: 0x0600003A RID: 58 RVA: 0x00002124 File Offset: 0x00000324
		public void SetOption(string key, object value)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			if (value == null)
			{
				this.options.Remove(key);
				return;
			}
			this.options.Remove(key);
			this.options.Add(key, value);
		}

		// Token: 0x04000001 RID: 1
		private volatile ChannelFactory factory;

		// Token: 0x04000002 RID: 2
		private volatile Dictionary<string, object> options = new Dictionary<string, object>();
	}
}
